﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Input;
using Squog_1._1.Managers;

using SquogContentPipeline;

namespace Squog_1._1.Menu
{
    class LevelWindow : Window
    {
        private bool IsPaused;
        private string MapName;

        public LevelWindow(string MapName)
            : base(new Vector2(1,1),new Vector2(0,0))
        {
            IsPaused = false;
            InputManager.LockMouse();

            this.MapName = MapName;

            //Game1.Squog.Reset(LevelMap.StartingPosition, Game1.physicsManager);

            //Add squog to the Managers
            //PhysicsManager.Add(Game1.Squog);
            //DrawManager.Add(Game1.Squog);
            
            //Add the DrawableObjects to DrawManager and PhysicsManager
            //foreach (GameObject o in LevelMap.objects)
            //{
            //    if (o is DrawableObject)
            //        Game1.drawManager.Add((DrawableObject)o);
            //    else if (o is PhysicsObject)
            //        Game1.physicsManager.Add((PhysicsObject)o);
            //}

            //Game1.drawManager.Background = LevelMap.BG;

            //Game1.drawManager.LockCamera = true;

            //Game1.drawManager.SetTerrain(LevelMap.TheTerrain);
        }

        public override void LoadContent(ContentManager Content)
        {
            Content.Load<MapData>(@"Maps/" + MapName);

            //DrawManager.LoadSpriteSheet("tree", 1, 1);
            //DrawManager.LoadSpriteSheet("bush", 1, 1);
            //DrawManager.LoadSpriteSheet("Sprites/Monster", 1, 1);
            //DrawManager.LoadSpriteSheet("fast", 5, 2);

            base.LoadContent(Content);
        }

        public override void Update(GameTime gameTime)
        {
            //if (InputManager.OnPress(Buttons.Start, 0))
            //{
            //    windowManager.AddWindow(new PauseWindow(windowManager));
            //    Game1.Paused = true;
            //}

            ////This should be moved to a pause window.
            //if (InputManager.OnPress(Buttons.Back, 0))
            //{
            //    Game1.physicsManager.Clear();
            //    Game1.drawManager.Clear();
            //    Game1.Objects.Clear();
            //    InputManager.UnlockMouse();
            //    windowManager.ChangeWindows(new MainWindow(windowManager));
            //    Game1.drawManager.LockCamera = false;
            //}
        }
    }
}
